<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 3. 用户输入一个整数n：

求1! + 2! + 3! + 4! + …… + n!的和

叹号表示阶乘，如4! = 1 * 2 * 3 * 4 -->
    <script>
        var a =parseInt(prompt("请输入一个整数",2));
            function fibo(a){
                if (a === 1) {
                    return 1;
                } else {
                    return  a * fibo(a - 1);
                }
            }
        var sub = 0;
            for (var i = 1; i <= a; i++) {
                sub+=fibo(i);
            }
            console.log(sub);
    </script>
</body>
</html>